package com.example.demo.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.example.demo.custom.BaseRepository;
import com.example.demo.entity.CarKeep;
import com.example.demo.entity.CarKeep2;
@Repository
public interface CarKeep2Repository extends BaseRepository<CarKeep2, Integer>{

	List<CarKeep2> findByCarKeep(CarKeep car);

	List<CarKeep2> findByCarKeepId(Integer id);

	/**
	 * @param car
	 * @return 通过时间排序得到最新一条
	 */
	@Query(value = "SELECT  *  FROM car_keep2 t WHERE t.car_keep_id=? ORDER BY t.begin_date DESC LIMIT 1 ",nativeQuery=true)
	CarKeep2 findByCarKeep(Integer id);
	
}
